# Contributor: Jakub Jirutka <jakub@jirutka.cz>
# Maintainer: Jakub Jirutka <jakub@jirutka.cz>
pkgname=ruby-eventmachine
_gemname=eventmachine
pkgver=1.2.7
pkgrel=7
pkgdesc="Fast, simple event-processing library for Ruby programs"
url="https://github.com/eventmachine/eventmachine"
arch="all"
license="Ruby OR GPL-2.0-or-later"
checkdepends="ruby-test-unit"
makedepends="openssl-dev>3 ruby-dev"
source="https://github.com/eventmachine/eventmachine/archive/v$pkgver/$pkgname-$pkgver.tar.gz
	improve-line_protocol-speed.patch
	remove-debug-puts-from-connection.patch
	fix-pure_ruby-intra-iteration-delete.patch
	fixes-for-process-status-in-ruby-3.patch
	fix-intermittent-tests.patch
	test_httpclient2-increase-timeout.patch
	0001-OpenSSL-1.1.0-test-updates.patch
	0002-Update-runtime-files-for-TLS13-no-SSL-OpenSSL-lib-info.patch
	0003-Move-console-SSL-Info-code-to-em_test_helper.patch
	0004-Openssl-1.1.1-updates.patch
	0005-Increase-certificate-length.patch
	0006-Bump-TLS-version.patch
	gemspec.patch
	"
builddir="$srcdir/$_gemname-$pkgver"
# XXX: Some tests fail. This rubygem is no longer maintainer, so we should
#  probably remove this aport soon.
options="!check"

build() {
	gem build $_gemname.gemspec
	gem install \
		--local \
		--install-dir dist \
		--ignore-dependencies \
		--no-document \
		--verbose \
		$_gemname
}

check() {
	# test_defers somtimes hangs
	GEM_PATH='./dist' ruby -Itests -e "Dir.glob './tests/**/test_*.rb', &method(:require)" -- \
		--verbose \
		--ignore-name=/^test_em_system_pid$/ \
		--ignore-name=/^test_invalid_address_bind_connect_dst$/ \
		--ignore-name=/^test_invalid_address_bind_connect_src$/ \
		--ignore-name=/^test_localhost$/ \
		--ignore-name=/^test_defers$/
}

package() {
	local gemdir="$pkgdir/$(ruby -e 'puts Gem.default_dir')"
	cd "$builddir"/dist

	mkdir -p "$gemdir"
	cp -r extensions gems specifications "$gemdir"/

	# Remove unnecessary files and rubbish...
	find "$gemdir"/extensions/ -name mkmf.log -delete

	cd "$gemdir"/gems/$_gemname-$pkgver
	rm -r ext/ lib/*.so
}

sha512sums="
768ec084903dce4c737cf564fce7886a3e7e5b7d4a89c2baea3e998130c53dc00488eaa2d8e9b0133d9e4d8fffbde80c3025403881486a7968c2d84425cc1f50  ruby-eventmachine-1.2.7.tar.gz
4237147991ce775d09606652cd299c185664ddff064bb96adceec4f5d6643d703e6f82de6d60963182931a715cc6823d12a84b867d487eb31ca45f3e026b7964  improve-line_protocol-speed.patch
aec12965c0f4642ad16b6bb17d25ff594de93b25e85c57062fdc0fd579c17a096d298f9e5bef4eac35da9c2786dad53d8045608c74d2f656e45bee7a5b7ea994  remove-debug-puts-from-connection.patch
e3031ab3805b69455361b7d1db8ca363cec32383fcd1cb6558568c897175deae5b7e93d7ade41d5965c547c3081fc54bc592ded25a1d47be08462825b98ee004  fix-pure_ruby-intra-iteration-delete.patch
919c65c0e6bcb2f7aada4c426859529e67f945e1840298b32889c5259dc2d638c06275f03d44d3fb13825cea741f6481b9b2b1ff8628e256f38c6eb85361ca93  fixes-for-process-status-in-ruby-3.patch
4ad075db2839206f3caa4ff296d8555b560a2ec77623b3a868f669e33476157d2372e41c17533a4807041b7b80f97981611c9c6beb8f356f67b7ad01d6705392  fix-intermittent-tests.patch
7f5ae8511e5b0d9624853affe45ba555ad36b202cb4fe9675262177d6f1340b20c15d1296fd2a1c62a59bb1862fc945e6ec6cd7a2760fb6ff1d8926ea0a0bd2c  test_httpclient2-increase-timeout.patch
e98deb058f87b0e7f7830ee02c738d35037c42ed8eb9b24e13655d64fd026395ad2cec98ad9247732e27f3908e5c494fb6e6e7118348c4349f438d4bc7558438  0001-OpenSSL-1.1.0-test-updates.patch
f5b90ac939a543eef560cdb1049d6dff786ee221aea1244eb11dd307954b3236cc89dc197aaf76661f8e906b4cbadf8e8944efbeca1345bd83edb407fc625527  0002-Update-runtime-files-for-TLS13-no-SSL-OpenSSL-lib-info.patch
4bec319a0c452361ec5119fc20892ab8496087a03767ea539318bf35908835af034280d748b6cf504e7015c2d193dc3b38c669d2301b64f14f69d54760c9525d  0003-Move-console-SSL-Info-code-to-em_test_helper.patch
a70825d8c7bf42c803a214e58be1cb7996fb2017bd0abc65e231729a01b5e9ae9bfc3db01f5fa70366abc717fdc3474764c8d7cd238dc3154016717715edbea6  0004-Openssl-1.1.1-updates.patch
cba2a93258410ca1e22c2c86ace55d5a303758caa09111a832ba448a92dd6e554f32e745da182c2ec4144b1d58e14852e51f77d5452d82687f6792010c08f6a0  0005-Increase-certificate-length.patch
f37c88a7571a65007745258758ccbfa95bde122a2ef604022dc83cdfe5af239160feb6087b9cc49f64317f7669702ff42bef9d3ff58be3d5b86c9acaa228ee69  0006-Bump-TLS-version.patch
e996c5cf94baf4c38909ec5383fe6fcac2b870f936adf0ff020064575ce016569b66921169b786f2ad5304de8c086a0a23371bbec9cd2cb8b6dd3372c5aee3ae  gemspec.patch
"
